<template>
  <div class="career">
    <div class="header">
      <span>事业机会</span>
    </div>
    <div class="line"></div>
    <el-button class="change" @click="handleClick">+新增事业机会</el-button>
    <el-table 
   :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
    :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="序号" width="100" />
      <el-table-column prop="name" label="岗位名称" width="150" />
      <el-table-column prop="job" label="职位简介" width="150" />
      <el-table-column prop="valueHtml" label="主要职责" width="200">
        <template #default="scope">
          <div v-html="scope.row.valueHtml"></div>
        </template>
      </el-table-column>
      <el-table-column prop="valueHtml1" label="基本要求" width="200">
        <template #default="scope">
          <div v-html="scope.row.valueHtml1"></div>
        </template>
      </el-table-column>
      <el-table-column prop="zip" label="操作时间" width="200" />
      <el-table-column label="操作" width="200">
        <template #default="scope">
          <el-button
            link
            type="primary"
            size="small"
            @click="handleClickbj(scope.row.id)"
            >编辑</el-button
          >
          <el-button
            link
            type="primary"
            size="small"
            @click="handleLook(scope.row.id)"
            >查看</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination"
      popper-class=""
      v-model:currentPage="currentPage3"
      v-model:page-size="pageSize3"
      :background="true"
      layout="prev, pager, next, jumper"
      :total="tableData.length"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import dayjs from "dayjs";
import { ref, reactive } from "vue";
import { useCareerStore } from "../../store/career";

const store = useCareerStore();
const tableData = ref([]);
tableData.value = store.carerrPost;
const router = useRouter();
// const text = store.carerrPost[2].valueHtml;
// const test = {}
//   text.forEach(item => {
//     test[item.valueHtml] = item.value
// });
// console.log(test)

//跳转添加事业机会
const handleClick = () => {
  router.push({
    path: "/change",
  });
};
//跳转编辑页面
const handleClickbj = (id) => {
  router.push({
    path: "/change",
    query: {
      id,
    },
  });
};
const currentPage3 = ref(1);
const pageSize3 = ref(10);
const handleSizeChange = (val) => {
  return `${val} items per page`;
};
const handleCurrentChange = (val) => {
  return `current page: ${val}`;
};

//跳转查看界面
const handleLook = (id) => {
  router.push({
    path: "/change",
    query: {
      id,
    },
  });
};
</script>

<style lang="less" scoped>
.header {
  width: 100%;
  height: 40px;
  padding: 5px;
  color: rgb(255, 153, 0);
  line-height: 30px;
  span {
    display: inline-block;
    width: 100px;
    height: 26px;
    border-left: 6px solid rgb(255, 153, 0);
    padding: 5px;
  }
}
.change {
  background-color: rgb(255, 153, 0);
  color: #fff;
  margin-left: 5px;
}
.pagination {
  float: right;
}
.line {
  height: 10px;
  width: 100%;
  background-color: rgb(246, 239, 239);
}
</style>
